<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use fast\Tree;
use think\Db;

/**
 *
 *
 * @icon fa fa-circle-o
 */
class Channel extends Backend
{

    /**
     * Channel模型对象
     * @var \app\admin\model\Channel
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\Channel;

    }



    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
    public function getList()
    {

        $list = Db::name("channel")->where('deletetime',null)->select();
        return json($list);
    }
    public function getStatus(){
        $admin_data = Db::name("admin")->where(['id'=>$this->auth->id])->find();
        $arr = [];
        if($admin_data['type'] == 3){
            $arr[4]['id'] = 4;
            $arr[4]['name'] = '待工厂收货';
            $arr[5]['id'] = 5;
            $arr[5]['name'] = '工厂检测中';
            $arr[9]['id'] = 9;
            $arr[9]['name'] = '待工厂寄出';
            $arr[10]['id'] = 10;
            $arr[10]['name'] = '已完成';



        }else{
            $arr[0]['id'] = 1;
            $arr[0]['name'] = '待审核';
            $arr[1]['id'] = 2;
            $arr[1]['name'] = '已驳回';
            $arr[3]['id'] = 3;
            $arr[3]['name'] = '待用户寄出';
            $arr[4]['id'] = 4;
            $arr[4]['name'] = '待工厂收货';
            $arr[5]['id'] = 5;
            $arr[5]['name'] = '工厂检测中';
            $arr[6]['id'] = 6;
            $arr[6]['name'] = '待确认检查结果';
            $arr[7]['id'] = 7;
            $arr[7]['name'] = '待上传凭证';
            $arr[8]['id'] = 8;
            $arr[8]['name'] = '凭证待审核';
            $arr[9]['id'] = 9;
            $arr[9]['name'] = '待工厂寄出';
            $arr[10]['id'] = 10;
            $arr[10]['name'] = '已完成';
            $arr[11]['id'] = 11;
            $arr[11]['name'] = '已撤回';
        }
        return json($arr);
    }

}
